package com.alibaba.citrus.ots.b2b.trade.order.dto.enums;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public enum OrderStatus {

    BEFORE_SUBMIT(1, "待提交"),

    BEFORE_DELIVERY(2,"待交货"),

    PARTIAL_DELIVER(3,"部分交货"),

    COMPLETED(4,"已完成"),

    CANCELLED(-1,"已取消"),

    SHIPPED(5,"已发货"),

    STAY_PUSH(6,"待推送"),

    PARTIAL_HANDLE(11,"部分处理"),

    WAIT_HANDLE(12,"待处理"),

    WAIT_RECEIVING(13,"待收货"),

    PART_RECEIVING(14,"部分收货");



    private static final Map<Integer, OrderStatus> CODE_MAP = Collections.unmodifiableMap(
            new HashMap<Integer, OrderStatus>() {
                {
                    for (OrderStatus status : OrderStatus.values()) {
                        put(status.getCode(), status);
                    }
                }
            });


    /**
     * 根据枚举 code 获取枚举对象
     */
    public static OrderStatus codeOf(Integer code) {
        return CODE_MAP.get(code);
    }

    /**
     * code
     */
    private Integer code;

    private String desc;

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    OrderStatus(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

}